﻿@using SAB.Domain.Loan;
@{
    ViewBag.Title = "Detalle";
}

<div class="row">
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li>@Html.ActionLink("Home", "Index", "Home")</li>
            <li>@Html.ActionLink("Préstamos", "LoanRegister", "Loan")</li>
            <li>@Html.ActionLink("Búsqueda", "LoanSearch", "Loan")</li>
            <li class="active">Detalle</li>
        </ol>
    </div>
</div>


<div class="row">
    <div class="col-md-12 title">
        <h1>Detalle Préstamo</h1>
    </div>
</div>

<div class="col-md-10">
    @{Loan l = (Loan)ViewData["loan"]; }
    <form action="@Url.Action("Update", "Loan", new { id = @l.Id })" method="post">

        <div class="form-group">
            <div class="row">
                <div class="col-md-6">
                    <label for="searchText">Nombre de la Publicación:</label>
                    <input class="form-control" type="text" value="@l.Loan_Item.Publication.Title" disabled>
                </div>
                <div class="col-md-6">
                    <label for="searchText">Cód. de Item:</label>
                    <input class="form-control" id="disabledImput" type="text" value=@l.Loan_Item.Id disabled>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-6">
                    <label for="searchText">Cód. de Usuario:</label>
                    <input class="form-control" id="disabledImput" type="text" value=@l.Loan_User.Id disabled>
                </div>
                <div class="col-md-6">
                    <label for="searchText">Fecha de Inicio:</label>
                    <input class="form-control" id="disabledImput" type="text" value=@l.Register_Date.ToString("d") placeholder="25/09/2014" disabled>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-6">
                    <label for="searchText">Estado:</label>
                    <input class="form-control" id="disabledImput" type="text" value=@l.Status disabled>
                </div>
                <div class="col-md-6">
                    <label for="searchText">Fecha Fin:</label>
                    <input class="form-control" id="disabledImput" type="text" value=@l.End_Date.ToString("d") disabled>
                </div>
            </div>
        </div>
        

        <div class="form-group">
            <div class="row">
                @if (l.Status == "Activo" || l.Status == "Pendiente")
                {
                    <div class="col-md-6">
                        <button class="btn btn-primary pull-right" data-toggle="modal" data-target="#myModal">Devolver</button>
                    </div>
                    <div class="col-md-2">
                        <button class="btn btn-primary pull-right" data-toggle="modal" data-target="#myDeleteModal">Dar de baja</button>
                    </div>
                    <div class="col-md-4">
                    </div>
                }
            </div>
        </div>

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title" id="myModalLabel">Confirmación</h4>
                    </div>
                    <div class="modal-body">
                        <div>
                            <label class="control-label">
                                <!--for="inputFechaInicio" class="control-label"-->
                                ¿Estas seguro que quieres registrar
                            </label>
                            <label class="control-label">
                                la finalización de este Préstamo?
                            </label>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                        <button type="submit" class="btn btn-primary" onclick="window.location.href='LoanFinished'">Aceptar</button>
                    </div>

                </div>
            </div>
        </div>
    </form>
</div>

<form action="@Url.Action("Delete", "Loan")" method="post">
    <div class="modal fade" id="myDeleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">Confirmación</h4>
                </div>
                <div class="modal-body">
                    <div>
                        <label class="control-label">
                            <!--for="inputFechaInicio" class="control-label"-->
                            ¿Estas seguro que quieres
                        </label>
                        <label class="control-label">
                            dar de baja a este Préstamo?
                        </label>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                    <button id="" class=" btn btn-primary">Aceptar</button>
                </div>

            </div>
        </div>
    </div>
</form>
